<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../js/layui/css/layui.css"/>
    <script src="../js/layui/layui.js"></script>
    <script src="../js/jquery/jquery-1.9.1.js"></script>
</head>
<body>
<table id="date" lay-filter="test" ></table>
<div id="toolbar" style="display: none;">

    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</div>

</body>
<script>

    layui.use(['table','layer','form','element'], function() {
        var table = layui.table;
        var element = layui.element;
        var layer = layui.layer;
        var form = layui.form;
        $(function () {
            var tableList = table.render({
                elem: '#date',
                fit: true,
                cellMinWidth: true, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                url: '../web/queryzhiwei', //数据接口
                type: "POST",
                loading: false,
                page: true,//开启分页
                limits: [1,5,30,40,50,60,70,80,90],//page 代表当前页码、limit 代表每页数据量
                cols: [
                    [ //表头
                        {type: 'checkbox',title: '全选', fixed: 'left'},
                        {field: 'id', title: 'ID', sort: true, align: 'center', fixed: 'left'},
                        {field: 'workname', title: '职位名称', align: 'center', sort: true},
                        {field: 'workingplace', title: '工作地点', align: 'center', sort: true},
                        {field: 'wage', title: '期望薪资', align: 'center', sort: true,templet:function(data){
                            return data.wage+"k";
                            }},
                        {field: 'hangye', title: '职位行业', align: 'center', sort: true},
                        {field: 'email', title: '邮箱', align: 'center', sort: true},
                        {fixed: 'right',title: '操作', width: 250, align: 'center', toolbar: '#toolbar'}
                    ]
                ]
            });
        })

        // 监听你的表格
        table.on('tool(test)', function(obj) {
            var data = obj.data;
            var id = data.id

            //  查看ID  ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓  方法
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');

                //删除  ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓  方法
            }
            if (obj.event === "del") {
                $.ajax({
                    url: "../web/delcjq",
                    type: "post",
                    data: {id: data.id},
                    success: function (data) {
                        if (data != "1") {
                            layer.msg(data.id);
                            layer.msg("删除失败", {icon: 5});
                        } else {
                            /* layer.msg(data.id);*/
                            layer.msg("删除成功", {icon: 6});
                            table.reload("date", {})  //自动刷新
                            //关闭弹框
                            layer.close(index);
                            /*  layer.msg("删除成功");*/
                        }
                    }
                })
            }

        })
        })
</script>
</html>